#ifndef __IO_H
#define __IO_H
#include"stdint.h"

//send byte data to port
static inline void outb(uint8_t data,uint16_t port){
	asm volatile ("outb %b0,%w1": :"a"(data),"Nd"(port));
}

//from port read byte data
static inline uint8_t inb(uint16_t port){
	uint8_t data;
	asm volatile ("inb %w1,%b0":"=a"(data):"Nd"(port));
	return data;
}

//send count word datas to port
static inline void outsw(const void* datas,uint32_t count,uint16_t port){
	asm volatile("cld ; rep outsw":"+S"(datas),"+c"(count):"Nd"(port));	
}

//from port read count word datas to buffer
static inline void insw(const void* buffer,uint32_t count,uint16_t port){
	asm volatile("cld ; rep insw":"+c"(count),"+D"(buffer):"Nd"(port):"memory");
}

#endif
